import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    host: "0.0.0.0",
    proxy: {
      "/api": {
        target: "http://localhost:9000",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      "/test": {
        target: "http://tengyuxin-bucket.oss-cn-beijing.aliyuncs.com",
        ws: true,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/test/, '')
      },
      '/strlike': {
        target: 'http://localhost:8080',
        changeOrigin: true,
      },
      '/sclike': {
        target: 'http://localhost:8080',
        changeOrigin: true,
      },
      // 新增 /mw 代理配置
      '/mw': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        // 如果不需要重写路径，可以保留原路径
        // rewrite: (path) => path.replace(/^\/mw/, '')
      }
    }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }
});